package com.happy.zebra.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.happy.zebra.admin.api.entity.MemberActivateEntity;
import com.happy.zebra.admin.api.entity.OnlineAllocateRecordEntity;
import com.happy.zebra.admin.api.vo.AllocateVO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface AllocateMapper extends BaseMapper<MemberActivateEntity> {

	IPage<AllocateVO> getOptPage(IPage<AllocateVO> page, @Param("name") String name, @Param("startDate") String startDate,
			@Param("endDate") String endDate);

	IPage<AllocateVO> getOrgPage(IPage<AllocateVO> page, @Param("name") String name, @Param("startDate") String startDate,
			@Param("endDate") String endDate);

	IPage<AllocateVO> getStudioPage(IPage<AllocateVO> page, @Param("name") String name, @Param("startDate") String startDate,
			@Param("endDate") String endDate);

	IPage<AllocateVO> getOnlineOptPage(@Param("page") IPage<AllocateVO> page, @Param("name") String name,
			@Param("phone") String phone);

	IPage<AllocateVO> getOnlineOrgPage(IPage<AllocateVO> page, @Param("name") String name, @Param("optId") Integer optId,
			@Param("phone") String phone);

	IPage<AllocateVO> getOnlineStudioPage(IPage<AllocateVO> page, @Param("name") String name, @Param("optId") Integer optId,
			@Param("phone") String phone);

	int insertOnlineRecord(@Param("entity") OnlineAllocateRecordEntity entity);

	IPage<OnlineAllocateRecordEntity> getOnlineRecord(@Param("page") IPage<OnlineAllocateRecordEntity> page,
			@Param("optId") Integer optId,
			@Param("targetOptId") Integer targetOptId, @Param("targetOrgId") Integer targetOrgId, @Param("startDate") String startDate,
			@Param("endDate") String endDate, @Param("name") String name, @Param("stockOptName") String stockOptName);

	int allocateOnlineOpt(@Param("optId") Integer optId, @Param("duration") Integer duration);

	int allocateOnlineOrg(@Param("orgId") Integer myOptId, @Param("orgId") Integer orgId, @Param("duration") Integer duration);

	Integer getOnlineCourseAvail(@Param("optId") Integer optId, @Param("orgId") Integer orgId);

	int getUDID(@Param("udid") String udid, @Param("optId") Integer optId);

	int allocateFromOptToOrg(@Param("duration") Integer duration, @Param("number") Integer number, @Param("optId") Integer optId,
			@Param("orgId") Integer orgId);

	int allocateUDID(@Param("list") List<String> list, @Param("optId") Integer optId, @Param("orgId") Integer orgId);

	int saveOrUpdateStock(@Param("id") Integer id, @Param("goodsId") Integer goodsId, @Param("goodsQuantity") Integer goodsQuantity,
			@Param("optId") Integer optId, @Param("orgId") Integer orgId);

	int countStockRow(@Param("goodsId") Integer goodsId, @Param("optId") Integer optId, @Param("orgId") Integer orgId);

	int countStockId(@Param("goodsId") Integer goodsId, @Param("optId") Integer optId, @Param("orgId") Integer orgId);

	int getStockByGoodsId(@Param("id") Integer id, @Param("optId") Integer optId, @Param("orgId") Integer orgId);
}